package com.atguigu.guli.gmall.gateway.config;

import com.atguigu.gmall.common.utils.RsaUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.security.PublicKey;

@Configuration
@Data
@Slf4j
@ConfigurationProperties(prefix = "auth.jwt")
public class JwtProperties {
    String publicKeyFilePath;//: F:\\keys\\rsa.pub
    String cookieTokenName;//: GMALL-TOKEN

    private PublicKey publicKey;
    @PostConstruct
    public void init(){
        try {
            publicKey = RsaUtils.getPublicKey(publicKeyFilePath);
        } catch (Exception e) {
//            e.printStackTrace();
            log.error("初始化公钥失败");
        }
    }
}
